package com.h3c.nem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.h3c.nem.entity.OfferAttachmentfiles;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * (OfferAttachmentfiles)表数据库访问层
 *
 * @author makejava
 * @since 2022-06-22 19:20:51
 */
public interface OfferAttachmentfilesMapper extends BaseMapper<OfferAttachmentfiles> {

    @Select("select * from Offer_AttachmentFiles a where exists (select 1 from Offer_Send_Detail b where a.offerid = b.id )")
    public List<OfferAttachmentfiles> queryValidHrssAttachFiles();

    @Select("SELECT a.* FROM Offer_AttachmentFiles AS a \n" +
            "WHERE\n" +
            "EXISTS ( SELECT 1 FROM Offer_Send_Detail b WHERE a.OfferId = b.ID ) \n" +
            "AND 2 > ( SELECT count(*) FROM Offer_AttachmentFiles WHERE OfferId = a.OfferId AND Type = 2 AND IsHighest = 0 AND ID > a.ID ) \n" +
            "AND Type = 2  AND IsHighest = 0 ")
    List<OfferAttachmentfiles> queryStudyAttachmentFiles();
}

